package com.koron.plan.web.maintainplan.bean.convertor;

import com.koron.plan.web.maintainplan.bean.dto.*;
import com.koron.plan.web.maintainplan.bean.entity.*;
import com.koron.plan.web.maintainplan.bean.vo.MaintainPlanDispatchDetailVO;
import com.koron.plan.web.maintainplan.bean.vo.MaintainPlanStandardVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @author twcao
 * @title: MaintainConvertor
 * @projectName GDH_EAM_V2
 * @description: 维保计划转化
 * @date 2022/3/114:38
 */
@Mapper(componentModel = "spring")
public interface MaintainConvertor {

    List<MaintainReadyPo> readysToReadyPos(List<MaintainPlanReadyBean> ready);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "maintainId", ignore = true),
            @Mapping(target = "type", source = "type"),
            @Mapping(target = "tools", source = "tools"),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "deleteFlag", ignore = true)
    })
    MaintainReadyPo readyToReadyPo(MaintainPlanReadyBean ready);

    List<MaintainEquipmentPo> standardsToStandardPos(List<MaintainPlanStandardVO> standards);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "maintainId", ignore = true),
            @Mapping(target = "equipmentId", source = "equipmentId"),
            @Mapping(target = "equipmentName", source = "equipmentName"),
            @Mapping(target = "standardId", source = "workId"),
            @Mapping(target = "standardName", source = "workName"),
            @Mapping(target = "sort", source = "sort"),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "deleteFlag", ignore = true)
    })
    MaintainEquipmentPo standardToStandardPo(MaintainPlanStandardVO standard);

    List<OrderInstructionBean> instructsToInstructs(List<MaintainPlanInstructionBean> standard);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "orderType", ignore = true),
            @Mapping(target = "bussinessId", source = "planId"),
            @Mapping(target = "instructionId", source = "instructionId"),
            @Mapping(target = "instructionName", source = "instructionName"),
            @Mapping(target = "sort", source = "sort"),
            @Mapping(target = "createTime", ignore = true)
    })
    OrderInstructionBean instructToInstruct(MaintainPlanInstructionBean standard);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "orderType", ignore = true),
            @Mapping(target = "orderId", ignore = true),
            @Mapping(target = "context", ignore = true),
            @Mapping(target = "orderDispatchWorker", source = "workers"),
            @Mapping(target = "orderWorkDeptPoList", source = "workerDept"),
    })
    OrderDispatchDto dispatchToDispatchDTO(MaintainPlanDispatchDetailVO detail);

    List<OrderDispatchWorker> dispatchWorkersToDispatchWorkers(List<MaintainPlanDispatchWorkerBean> workers);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "orderId", ignore = true),
            @Mapping(target = "deleteFlag", ignore = true),
            @Mapping(target = "type", source = "staffType")
    })
    OrderDispatchWorker dispatchWorkerToDispatchWorker(MaintainPlanDispatchWorkerBean worker);

    List<OrderWorkDeptPo> dispatchWorkerDeptsToDispatchDepts(List<MaintainPlanDispatchDept> depts);

    @Mappings({
            @Mapping(target = "orderId", ignore = true),
            @Mapping(target = "orderType", ignore = true),
            @Mapping(target = "teamId", ignore = true)
    })
    OrderWorkDeptPo dispatchDeptToDispatchDept(MaintainPlanDispatchDept worker);

    List<OrderEquipPo> equipsToEquips(List<PlanEquipment> equipments);

    @Mappings({
            @Mapping(target = "orderId", ignore = true),
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "orderType", ignore = true)
    })
    OrderEquipPo equipToEquip(PlanEquipment equipment);
}
